package com.chima.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.chima.domain.Department;
import com.chima.domain.Jobstyle;
import com.chima.service.JobstyleService;

public class JobstyleDao extends HibernateDaoSupport{
	//分页查询
			public List<Jobstyle> findByCriteria(DetachedCriteria criteria, int firstResult,int maxResults) {
				return this.getHibernateTemplate().findByCriteria(criteria,firstResult,maxResults);
			}
		   //查找总页数
			public int findByTotalCount() {
				List list= this.getHibernateTemplate().find("select count(*) from Jobstyle");
				long temp = (Long) list.get(0);
				return (int) temp;
			}
			public void save(Jobstyle jobstyle) {
				this.getHibernateTemplate().save(jobstyle);
			}
			public void update(Jobstyle jobstyle) {
				this.getHibernateTemplate().update(jobstyle);
				
			}
			
			public void delete(int id) {
				this.getHibernateTemplate().delete(this.getHibernateTemplate().load(Jobstyle.class, id));
			}

}
